home *** CD-ROM | disk | FTP | other *** search
/ Champak 119 / (Vol 119) Nov 09 2010.iso / TGKI-109 / Games / agent_platformer.swf / scripts / frame_3 / DoAction.as
Text File  |  2010-11-09  |  8KB  |  229 lines

  1. function update()
  2. {
  3.    player._x = 40;
  4.    player._y = 40;
  5.    forecast_x = 40;
  6.    forecast_y = 40;
  7.    rcan = false;
  8.    jumping = false;
  9.    has_jetpack = true;
  10.    using_jetpack = false;
  11.    jet_bar.jet_bar_inside._width = 109;
  12.    xspeed = 0;
  13.    yspeed = 0;
  14.    max_yspeed = 10;
  15.    walk_speed = 4;
  16.    climb_speed = 2;
  17.    jet_speed = 3;
  18.    using_jetpack = false;
  19.    has_jetpack = true;
  20.    climbing = false;
  21.    jumping = false;
  22.    can_jump = true;
  23.    gravity = 1;
  24.    jump_power = 10;
  25.    walking_while_jumping = true;
  26.    show_score = "Coins : " + score;
  27.    rgain = 0;
  28.    _root.lava.removeMovieClip();
  29.    _root.exit_door.removeMovieClip();
  30.    _root.lev.removeMovieClip();
  31.    _root.moving.removeMovieClip();
  32.    _root.lad.removeMovieClip();
  33.    _root.lasers.removeMovieClip();
  34.    _root.coins.removeMovieClip();
  35.    _root.createEmptyMovieClip("exit",_root.getNextHighestDepth());
  36.    _root.createEmptyMovieClip("lev",_root.getNextHighestDepth());
  37.    _root.createEmptyMovieClip("lad",_root.getNextHighestDepth());
  38.    _root.createEmptyMovieClip("lava",_root.getNextHighestDepth());
  39.    _root.createEmptyMovieClip("moving",_root.getNextHighestDepth());
  40.    _root.createEmptyMovieClip("coins",_root.getNextHighestDepth());
  41.    _root.createEmptyMovieClip("lasers",_root.getNextHighestDepth());
  42.    lad.swapDepths(_root.player);
  43.    coins.swapDepths(_root.player);
  44.    decay = false;
  45.    y = 0;
  46.    while(y <= 14)
  47.    {
  48.       x = 0;
  49.       while(x <= 24)
  50.       {
  51.          if(level1[y][x] == 1)
  52.          {
  53.             place_brick = lev.attachMovie("block","block_" + lev.getNextHighestDepth(),lev.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  54.             place_brick.gotoAndStop(level1[y][x]);
  55.          }
  56.          if(level1[y][x] == 2)
  57.          {
  58.             ladder_brick = lad.attachMovie("block","block_" + lad.getNextHighestDepth(),lad.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  59.             ladder_brick.gotoAndStop(level1[y][x]);
  60.          }
  61.          if(level1[y][x] == 3)
  62.          {
  63.             lava_brick = lava.attachMovie("block","block_" + lava.getNextHighestDepth(),lava.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  64.             lava_brick.gotoAndStop(level1[y][x]);
  65.          }
  66.          if(level1[y][x] == 4)
  67.          {
  68.             moving_brick = moving.attachMovie("block","block_" + moving.getNextHighestDepth(),moving.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  69.             moving_brick.gotoAndStop(level1[y][x]);
  70.             moving_brick.dir = 1;
  71.             moving_brick.onEnterFrame = function()
  72.             {
  73.                this._x += this.dir;
  74.                if(_root.lev.hitTest(this._x + 11,this._y,true) and this.dir > 0 or _root.lev.hitTest(this._x - 10,this._y,true) and this.dir < 0)
  75.                {
  76.                   this.dir *= -1;
  77.                }
  78.                if(_root.player.hitTest(this._x,this._y - 11,true) or _root.player.hitTest(this._x + 5,this._y - 11,true) or _root.player.hitTest(this._x - 5,this._y - 11,true))
  79.                {
  80.                   player._x += this.dir;
  81.                }
  82.             };
  83.          }
  84.          if(level1[y][x] == 5)
  85.          {
  86.             exit_door = exit.attachMovie("block","block_" + exit.getNextHighestDepth(),exit.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  87.             exit_door.gotoAndStop(level1[y][x]);
  88.          }
  89.          if(level1[y][x] == 6)
  90.          {
  91.             coin = coins.attachMovie("block","block_" + coins.getNextHighestDepth(),coins.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  92.             coin.gotoAndStop(level1[y][x]);
  93.             coin.onEnterFrame = function()
  94.             {
  95.                if(_root.player.hitTest(this._x,this._y,true) or _root.player.hitTest(this._x + 5,this._y - 11,true) or _root.player.hitTest(this._x - 5,this._y - 11,true))
  96.                {
  97.                   score++;
  98.                   rgain++;
  99.                   if(jet_bar.jet_bar_inside._width < 108)
  100.                   {
  101.                      using_jetpack = false;
  102.                      has_jetpack = true;
  103.                      jet_bar.jet_bar_inside._width += 2;
  104.                   }
  105.                   removeMovieClip(this);
  106.                }
  107.             };
  108.          }
  109.          if(level1[y][x] == 7)
  110.          {
  111.             laser = lasers.attachMovie("block","block_" + lasers.getNextHighestDepth(),lasers.getNextHighestDepth(),{_x:x * 20 + 10,_y:y * 20 + 10});
  112.             laser.gotoAndStop(level1[y][x]);
  113.          }
  114.          x++;
  115.       }
  116.       y++;
  117.    }
  118. }
  119. stop();
  120. if(son_ == undefined)
  121. {
  122.    if(my_sound == undefined)
  123.    {
  124.       var my_sound = new Sound();
  125.       my_sound.attachSound("sound");
  126.       my_sound.start(0,99999);
  127.    }
  128.    stimer = 0;
  129.    sup = true;
  130.    son_ = true;
  131. }
  132. bgs.onEnterFrame = function()
  133. {
  134.    site.onRelease = function()
  135.    {
  136.       getUrl("http://www.granttitus.com", "");
  137.    };
  138.    if(sup == true)
  139.    {
  140.       stimer++;
  141.    }
  142.    if(Key.isDown(77))
  143.    {
  144.       if(son_ == true and stimer > 5)
  145.       {
  146.          sound.removeMovieClip();
  147.          stopAllSounds();
  148.          stimer = 0;
  149.          sup = true;
  150.          son_ = false;
  151.       }
  152.       if(son_ == false and stimer > 5)
  153.       {
  154.          var _loc1_ = new Sound();
  155.          _loc1_.attachSound("sound");
  156.          _loc1_.start(0,99999);
  157.          stimer = 0;
  158.          sup = true;
  159.          son_ = true;
  160.       }
  161.    }
  162. };
  163. attachMovie("cover","cover",_root.getNextHighestDepth());
  164. cover._alpha = 100;
  165. cover.onEnterFrame = function()
  166. {
  167.    this._alpha -= 6;
  168.    if(this._alpha <= 0)
  169.    {
  170.       removeMovieClip(this);
  171.    }
  172. };
  173. _root.lasers.removeMovieClip();
  174. _root.lava.removeMovieClip();
  175. _root.exit_door.removeMovieClip();
  176. _root.lev.removeMovieClip();
  177. _root.moving.removeMovieClip();
  178. _root.lad.removeMovieClip();
  179. _root.jet_bar.removeMovieClip();
  180. _root.player.removeMovieClip();
  181. _root.coins.removeMovieClip();
  182. level1 = new Array();
  183. _root.createEmptyMovieClip("exit",_root.getNextHighestDepth());
  184. _root.createEmptyMovieClip("lev",_root.getNextHighestDepth());
  185. _root.createEmptyMovieClip("lad",_root.getNextHighestDepth());
  186. _root.createEmptyMovieClip("lava",_root.getNextHighestDepth());
  187. _root.createEmptyMovieClip("moving",_root.getNextHighestDepth());
  188. _root.createEmptyMovieClip("coins",_root.getNextHighestDepth());
  189. level1[0] = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
  190. level1[1] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  191. level1[2] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  192. level1[3] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  193. level1[4] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  194. level1[5] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  195. level1[6] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  196. level1[7] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  197. level1[8] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  198. level1[9] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1);
  199. level1[10] = new Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
  200. level1[11] = new Array(1,0,0,0,0,0,1,0,0,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1);
  201. level1[12] = new Array(1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1);
  202. level1[13] = new Array(1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1);
  203. level1[14] = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
  204. update();
  205. start_btn.onRelease = function()
  206. {
  207.    _root.lava.removeMovieClip();
  208.    _root.exit_door.removeMovieClip();
  209.    _root.lev.removeMovieClip();
  210.    _root.moving.removeMovieClip();
  211.    _root.lad.removeMovieClip();
  212.    _root.jet_bar.removeMovieClip();
  213.    _root.player.removeMovieClip();
  214.    _root.coins.removeMovieClip();
  215.    _root.gotoAndStop("chose");
  216. };
  217. ins_btn.onRelease = function()
  218. {
  219.    _root.lava.removeMovieClip();
  220.    _root.exit_door.removeMovieClip();
  221.    _root.lev.removeMovieClip();
  222.    _root.moving.removeMovieClip();
  223.    _root.lad.removeMovieClip();
  224.    _root.jet_bar.removeMovieClip();
  225.    _root.player.removeMovieClip();
  226.    _root.coins.removeMovieClip();
  227.    _root.gotoAndStop("ins");
  228. };
  229.